#ifndef _COM_SERVICE_PROVIDER_H
#define _COM_SERVICE_PROVIDER_H

#include <mshtml.h>

/*namespace WinHtml
{
using struct ::IUnknown;
// import mshtml typlib
#import "libid:3050F1C5-98B5-11CF-BB82-00AA00BDCE0B" version(4.0) raw_interfaces_only, raw_native_types, no_namespace, named_guids, auto_search
}

using namespace WinHtml;*/

#include "npapi.h"

class ServiceStub : public IHTMLDocument2, public IServiceProvider
{
public:
	ServiceStub(NPP pluginInstance)
		: refCount(0)
	{
		this->pluginInstance = pluginInstance;
	}

	// IDispatch Methods
	HRESULT STDMETHODCALLTYPE GetTypeInfoCount( 
            /* [out] */ __RPC__out UINT *pctinfo);
        
    HRESULT STDMETHODCALLTYPE GetTypeInfo( 
        /* [in] */ UINT iTInfo,
        /* [in] */ LCID lcid,
        /* [out] */ __RPC__deref_out_opt ITypeInfo **ppTInfo);
    
    HRESULT STDMETHODCALLTYPE GetIDsOfNames(
        /* [in] */ __RPC__in REFIID riid,
        /* [size_is][in] */ __RPC__in_ecount_full(cNames) LPOLESTR *rgszNames,
        /* [range][in] */ UINT cNames,
        /* [in] */ LCID lcid,
        /* [size_is][out] */ __RPC__out_ecount_full(cNames) DISPID *rgDispId);
    
    HRESULT STDMETHODCALLTYPE Invoke( 
        /* [in] */ DISPID dispIdMember,
        /* [in] */ REFIID riid,
        /* [in] */ LCID lcid,
        /* [in] */ WORD wFlags,
        /* [out][in] */ DISPPARAMS *pDispParams,
        /* [out] */ VARIANT *pVarResult,
        /* [out] */ EXCEPINFO *pExcepInfo,
        /* [out] */ UINT *puArgErr);

	// IUnknown Methods
	HRESULT STDMETHODCALLTYPE QueryInterface(
                /* [in] */ REFIID riid,
                /* [iid_is][out] */ __RPC__deref_out void __RPC_FAR *__RPC_FAR *ppvObject);

    ULONG STDMETHODCALLTYPE AddRef();

    ULONG STDMETHODCALLTYPE Release();

	// IServiceProvider Method
	STDMETHOD(QueryService)(/* [in] */ REFGUID guidService, /* [in] */ REFIID riid, /* [out] */ void** ppvObject);

	// IHTMLDocument2 Methods
	STDMETHOD(get_all)(IHTMLElementCollection * * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_body)(IHTMLElement * * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_activeElement)(IHTMLElement * * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_images)(IHTMLElementCollection * * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_applets)(IHTMLElementCollection * * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_links)(IHTMLElementCollection * * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_forms)(IHTMLElementCollection * * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_anchors)(IHTMLElementCollection * * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_title)(BSTR p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_title)(BSTR * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_scripts)(IHTMLElementCollection * * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_designMode)(BSTR p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_designMode)(BSTR * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_selection)(IHTMLSelectionObject * * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_readyState)(BSTR * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_frames)(IHTMLFramesCollection2 * * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_embeds)(IHTMLElementCollection * * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_plugins)(IHTMLElementCollection * * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_alinkColor)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_alinkColor)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_bgColor)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_bgColor)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_fgColor)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_fgColor)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_linkColor)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_linkColor)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_vlinkColor)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_vlinkColor)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_referrer)(BSTR * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_location)(IHTMLLocation * * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_lastModified)(BSTR * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_URL)(BSTR p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_URL)(BSTR * p)
	{
		//SysAllocString(L"http://ws07:150/MyBlog/test1/Forms/AllItems.aspx")
		*p = GetUrl();
		
		return S_OK;
	}
	STDMETHOD(put_domain)(BSTR p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_domain)(BSTR * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_cookie)(BSTR p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_cookie)(BSTR * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_expando)(VARIANT_BOOL p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_expando)(VARIANT_BOOL * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_charset)(BSTR p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_charset)(BSTR * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_defaultCharset)(BSTR p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_defaultCharset)(BSTR * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_mimeType)(BSTR * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_fileSize)(BSTR * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_fileCreatedDate)(BSTR * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_fileModifiedDate)(BSTR * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_fileUpdatedDate)(BSTR * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_security)(BSTR * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_protocol)(BSTR * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_nameProp)(BSTR * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(write)(SAFEARRAY * psarray)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(writeln)(SAFEARRAY * psarray)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(open)(BSTR url, VARIANT name, VARIANT features, VARIANT replace, LPDISPATCH * pomWindowResult)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(close)()
	{
		return E_NOTIMPL;
	}
	STDMETHOD(clear)()
	{
		return E_NOTIMPL;
	}
	STDMETHOD(queryCommandSupported)(BSTR cmdID, VARIANT_BOOL * pfRet)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(queryCommandEnabled)(BSTR cmdID, VARIANT_BOOL * pfRet)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(queryCommandState)(BSTR cmdID, VARIANT_BOOL * pfRet)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(queryCommandIndeterm)(BSTR cmdID, VARIANT_BOOL * pfRet)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(queryCommandText)(BSTR cmdID, BSTR * pcmdText)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(queryCommandValue)(BSTR cmdID, VARIANT * pcmdValue)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(execCommand)(BSTR cmdID, VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL * pfRet)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(execCommandShowHelp)(BSTR cmdID, VARIANT_BOOL * pfRet)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(createElement)(BSTR eTag, IHTMLElement * * newElem)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_onhelp)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_onhelp)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_onclick)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_onclick)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_ondblclick)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_ondblclick)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_onkeyup)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_onkeyup)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_onkeydown)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_onkeydown)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_onkeypress)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_onkeypress)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_onmouseup)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_onmouseup)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_onmousedown)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_onmousedown)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_onmousemove)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_onmousemove)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_onmouseout)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_onmouseout)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_onmouseover)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_onmouseover)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_onreadystatechange)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_onreadystatechange)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_onafterupdate)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_onafterupdate)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_onrowexit)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_onrowexit)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_onrowenter)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_onrowenter)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_ondragstart)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_ondragstart)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_onselectstart)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_onselectstart)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(elementFromPoint)(long x, long y, IHTMLElement * * elementHit)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_parentWindow)(IHTMLWindow2 * * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_styleSheets)(IHTMLStyleSheetsCollection * * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_onbeforeupdate)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_onbeforeupdate)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(put_onerrorupdate)(VARIANT p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(get_onerrorupdate)(VARIANT * p)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(toString)(BSTR * String)
	{
		return E_NOTIMPL;
	}
	STDMETHOD(createStyleSheet)(BSTR bstrHref, long lIndex, IHTMLStyleSheet * * ppnewStyleSheet)
	{
		return E_NOTIMPL;
	}

	// IHTMLDocument Methods

	STDMETHOD(get_Script)(LPDISPATCH * p)
	{
		return E_NOTIMPL;
	}

private:

	BSTR GetUrl();

	NPP pluginInstance;

	ULONG refCount;

};

#endif
